package gases.as3.librarys.components.ui.container
{
	import gases.as3.librarys.components.skin.data.BaseSkin;
	import gases.as3.librarys.components.skin.data.PanelSkin;
	import gases.as3.librarys.components.ui.GSkinBox;
	import gases.as3.librarys.components.ui.GUIComponents;
	import gases.as3.librarys.components.ui.basic.GLabel;
	
	public class GTitle extends GUIComponents
	{
		/**
		 * title类
		 * @param w 宽
		 * @param h 高
		 * @param name 名字
		 * @param color 颜色
		 * 
		 */		
		public function GTitle(w:Number,h:Number,name:String = "",color:uint = 0x000000)
		{
			_width = w;
			_height = h;
			_name = name;
			_color = color;
			super();
		}
		
		override protected function initialization():void
		{
			super.initialization();
			_background = new GSkinBox();
			_label = new GLabel(_name, _color,12,120,20);
			
			_label.x = (_width - _label.width)/2;
			
			this.addChild(_background);
			this.addChild(_label);
		}
		
		override public function set skin(value:BaseSkin):void
		{
			_panelSkin = value as PanelSkin;
			super.skin = value;
			_background.source = _panelSkin.title_background;
			
			setWH();
		}
		
		
		override public function dispose():void
		{
			this.removeChild(_background);
			this.removeChild(_label);
			_background.dispose();
			_label.dispose();
			_background = null;
			_label = null;
			super.dispose();
		}
		
		private function setWH():void
		{
			_background.setHeight(_height);
			_background.setWidth(_width);
		}
		
		private var _panelSkin:PanelSkin;
		private var _width:Number;
		private var _height:Number;
		private var _name:String;
		private var _color:uint;
		private var _label:GLabel;
		private var _background:GSkinBox;
	}
}